package com.lagou.application;


import com.lagou.MyRunBoot;
import com.lagou.config.AppConfig;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

//@Component
public class SpringApplication {

    public static void run(Class<MyRunBoot> myRunBootClass, String[] args) throws Exception {
        //1、初始化IOC 通过注解的方式初始化Spring的上下文
        AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext();
        //注册spring的配置类（替代传统项目中xml的configuration）
        ac.register(AppConfig.class);
        ac.refresh();
        //2、获取&启动tomcat
        WebServerFactory webServerFactory = ac.getBean(WebServerFactory.class);
        webServerFactory.createServer();

    }
}
